public class Demo4 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()-> {
           Thread current = Thread.currentThread();
           while (!current.isInterrupted()){
               System.out.println("线程t运行");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   System.out.println("线程t运行结束");
                   break;
               }
           }

        });
        t.start();
        Thread.sleep(2000);
        System.out.println("main线程尝试结束t线程");
        t.interrupt();

    }
}
